package DecChallenges;

//https://leetcode.com/problems/calculate-money-in-leetcode-bank/description/?envType=daily-question&envId=2023-12-06
public class Day6_P1716 {
    public static void main(String[] args) {
        //如果都是这种笔试面试题那该多好？
    }
    public int totalMoney(int n) {
        int ans = 0, base = 1, pre = 28;
        while(n >= 7) {
            ans += pre;
            base++;
            pre += 7;
            n -= 7;
        }
        ans += (base + (base + n - 1)) * n / 2;
        return ans;
    }
}
